<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>插件-缩略图</title>
</head>

<body>
  <div style="position: relative;">
    <div id="mountNode"></div>
    <div id="minimap" style="border: 1px solid #999; position: absolute; top: 0px;"></div>
  </div>
  <script src="../build/g6.js"></script>
  <script src="../build/plugin.tool.minimap.js"></script>
  <script>
    const minimap = new G6.Plugins['tool.minimap']({
      container: 'minimap',
      width: 180,
      height: 120
    });
    G6.registerNode('html1', {
      draw(item) {
        const group = item.getGraphicGroup();
        return group.addShape('dom', {
          attrs: {
            x: 0,
            y: 0,
            width: 100,
            height: 100,
            html: `<div>
              <h1>${item.id}</h1>
              <div>吉林省地方； </div>
            </div>`
          }
        });
      }
    });
    G6.registerNode('html2', {
      draw(item) {
        const group = item.getGraphicGroup();
        const html = G6.Util.createDOM(`<div>
              <h1>${item.id}</h1>
              <div>吉林省地方； </div>
            </div>`);
        return group.addShape('dom', {
          attrs: {
            x: 0,
            y: 0,
            width: 100,
            height: 100,
            html
          }
        });
      }
    });
    const data = {
      nodes: [{
        id: 'node0',
        x: -100,
        y: 200,
        shape: 'html1'
      }, {
        id: 'node1',
        x: 100,
        y: 200,
        shape: 'html2'
      }, {
        id: 'node2',
        x: 300,
        y: 200,
        shape: 'html3'
      }, {
        id: 'node3',
        x: 600,
        y: 200,
        shape: 'html4'
      }],
      edges: [{
        target: 'node0',
        source: 'node1'
      }, {
        target: 'node2',
        source: 'node1'
      }, {
        target: 'node2',
        source: 'node3'
      }]
    };
    const graph = new G6.Graph({
      container: 'mountNode',
      fitView: 'cc',
      height: window.innerHeight,
      renderer: 'svg',
      plugins: [ minimap ]
    });
    graph.node({
      shape: 'custom'
    });
    graph.read(data);
  </script>
</body>
</html>
